﻿<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="ApplicationEdit.ascx.cs" Inherits="CentralOffice.WebClient.Tasks.ApplicationEdit" %>

<table class="TableBlock" width="90%" align="center">
    <tr><td nowrap class="TableData" style="width: 113px">申请类别：</td><td nowrap class="TableData"><asp:DropDownList ID="ddlCategory" runat="server"></asp:DropDownList></td></tr>
    <tr><td nowrap class="TableData" style="width: 113px">紧急程度：</td><td nowrap class="TableData"><asp:DropDownList ID="ddlUrgencyDegree" runat="server"></asp:DropDownList></td></tr>
    <tr><td nowrap class="TableData" style="width: 113px">申请编号：</td><td nowrap class="TableData"><asp:TextBox ID="txtApplicationCode" runat="server" CssClass="BigInput" style="width:82%"></asp:TextBox><asp:RegularExpressionValidator ID="RegularExpressionValidator2" runat="server" ErrorMessage="格式不正确" ValidationExpression="^\d{8}-\d{3}$" ControlToValidate="txtApplicationCode">(格式错误)</asp:RegularExpressionValidator></td></tr>
    <tr><td nowrap class="TableData" style="width: 113px">申请名称：</td><td nowrap class="TableData"><asp:TextBox ID="txtName" runat="server" CssClass="BigInput" style="width:82%"></asp:TextBox><span class="warning">（请先填写名称）</span><asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ErrorMessage="任务名称必须填写" ControlToValidate="txtName">*</asp:RequiredFieldValidator></td></tr>
    <%--<tr><td nowrap class="TableData" style="width: 113px">申请时间：</td><td nowrap class="TableData"><asp:TextBox ID="txtDateOfApplication" runat="server" CssClass="BigInput"></asp:TextBox>&nbsp;<img onclick="WdatePicker({el:$dp.$(ApplicationEdit1_txtDateOfApplication)})" src="../inc/js/My97DatePicker/skin/datePicker.gif" width="16" height="22" align="absmiddle"></td></tr>--%>
    <tr><td nowrap class="TableData" style="width: 113px">申请人：</td><td nowrap class="TableData">
    <asp:Literal ID="lblApplicant" EnableViewState="false" runat="server"></asp:Literal>
<%--    
    <asp:UpdatePanel ID="UpdatePanel2" runat="server" UpdateMode="Conditional" RenderMode="Inline"><ContentTemplate>
    <input type="text" id="txtApplicantReadOnly" style="width:82%" name="txtApplicantReadOnly" class="SmallStatic" runat="server" readonly="readonly" /><asp:HiddenField ID="txtApplicant" runat="server" />&nbsp;<asp:LinkButton ID="LinkButton1" CommandName="Applicant" runat="server" OnClick="btnShowPopup_Click" CssClass="orgAdd">选择</asp:LinkButton>
    </ContentTemplate><Triggers><asp:AsyncPostBackTrigger ControlID="btnOK" /></Triggers></asp:UpdatePanel>&nbsp;<a href="javascript:;" class="orgClear" onclick="$get('<%= txtApplicantReadOnly.ClientID %>').value='';$get('<%= txtApplicant.ClientID %>').value='';">清空</a>
    --%>
    </td></tr>
    
    <tr><td nowrap class="TableData" style="width: 113px">执行人：</td><td nowrap class="TableData">
    <asp:Literal ID="Literal1" EnableViewState="false" runat="server"></asp:Literal>
  
    <asp:UpdatePanel ID="UpdatePanel2" runat="server" UpdateMode="Conditional" RenderMode="Inline"><ContentTemplate>
    <input type="text" id="txtExecutorReadOnly" style="width:82%" name="txtExecutorReadOnly" class="SmallStatic" runat="server" readonly="readonly" /><asp:HiddenField ID="txtExecutor" runat="server" />&nbsp;<asp:LinkButton ID="LinkButton1" CommandName="Executor" runat="server" OnClick="btnShowPopup_Click" CssClass="orgAdd">选择</asp:LinkButton>
    </ContentTemplate><Triggers><asp:AsyncPostBackTrigger ControlID="btnOK" /></Triggers></asp:UpdatePanel>&nbsp;<a href="javascript:;" class="orgClear" onclick="$get('<%= txtExecutorReadOnly.ClientID %>').value='';$get('<%= txtExecutor.ClientID %>').value='';">清空</a>

    </td></tr>
    
    <tr><td nowrap class="TableData" style="width: 113px">审批内容：</td><td nowrap class="TableData"><asp:TextBox ID="txtApprovalContent" runat="server" CssClass="BigInput" TextMode="MultiLine" Rows="4" style="width:82%"></asp:TextBox></td></tr>
    <%--<tr><td nowrap class="TableData" style="width: 113px">发起人：</td><td nowrap class="TableData"><asp:TextBox ID="txtSponsor" runat="server" CssClass="BigInput" style="width:82%"></asp:TextBox>--%>
    <tr><td nowrap class="TableData" style="width: 113px">审批者：</td><td nowrap class="TableData">
    <asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional" RenderMode="Inline"><ContentTemplate>
    <input type="text" id="txtApprovedByReadOnly" style="width:82%" name="txtApprovedByReadOnly" class="SmallStatic" runat="server" readonly="readonly" /><asp:HiddenField ID="txtApprovedBy" runat="server" />&nbsp;<asp:LinkButton ID="btnShowPopup" CommandName="ApprovedBy" runat="server" OnClick="btnShowPopup_Click" CssClass="orgAdd">选择</asp:LinkButton>
    </ContentTemplate><Triggers><asp:AsyncPostBackTrigger ControlID="btnOK" /></Triggers></asp:UpdatePanel>&nbsp;<a href="javascript:;" class="orgClear" onclick="$get('<%= txtApprovedByReadOnly.ClientID %>').value='';$get('<%= txtApprovedBy.ClientID %>').value='';">清空</a>
    </td></tr>
    <tr><td class="TableData">附件：</td><td class="TableData"><asp:FileUpload ID="fileAttachments" runat="server" Width="78%" /></td></tr>
    <tr><td nowrap class="TableData" style="width: 113px">是否终审：</td><td nowrap class="TableData"><asp:CheckBox ID="chkIsFinal" runat="server" /></td></tr>
    <%--<tr><td nowrap class="TableData" style="width: 113px">最晚审批时间：</td><td nowrap class="TableData"><asp:TextBox ID="txtWarningDate" runat="server" CssClass="BigInput"></asp:TextBox>&nbsp;<img onclick="WdatePicker({el:$dp.$(ApplicationEdit1_txtWarningDate), dateFmt:'yyyy-MM-dd HH:mm:ss'})" src="../inc/js/My97DatePicker/skin/datePicker.gif" width="16" height="22" align="absmiddle" /></td></tr>--%>
    <%--
    <tr><td nowrap class="TableData" style="width: 113px">任务说明：</td><td nowrap class="TableData"><asp:TextBox ID="txtContentText" runat="server" CssClass="BigInput" TextMode="MultiLine" Rows="4" style="width:90%"></asp:TextBox></td></tr>
    <tr><td nowrap class="TableData" style="width: 113px">注意事项：</td><td nowrap class="TableData"><asp:TextBox ID="txtNotice" runat="server" CssClass="BigInput" TextMode="MultiLine" Rows="4" style="width:90%"></asp:TextBox></td></tr>
    --%>
    
   <tr><td nowrap class="TableControl" colspan="2" align="center"><asp:Button ID="btnSave" runat="server" Text="确定" CssClass="BigButton" 
   OnClick="btnSave_Click" 
   OnClientClick=" if(document.getElementById('ApplicationEdit1_txtApprovedBy').value.length == 0) { alert('您必须选定一个审批者！');  return false;}  if(document.getElementById('ApplicationEdit1_txtApprovedBy').value.indexOf(',') > 0) { alert('您只能选择一个审批者！');  return false;} var selIdx = document.getElementById('ApplicationEdit1_ddlUrgencyDegree').selectedIndex; var selText = document.getElementById('ApplicationEdit1_ddlUrgencyDegree').options[selIdx].text;return window.confirm('您确认此申请的紧急程度为 『' + selText + ' 』吗？');" /></td></tr><%--OnClientClick="alert(txtFileUpload1.value=encodeURIComponent(txtFileUpload1.value));"--%>
</table>


<asp:Panel ID="pnlPopup" runat="server" CssClass="x-pne" style="display:none; width:460px;">
    <asp:UpdatePanel ID="updPnlDepartment" runat="server" UpdateMode="Conditional">
    <ContentTemplate>
    
    <asp:HiddenField ID="txtSelectedObject" runat="server" />
    <asp:Button id="btnShowEdit" runat="server" style="display:none" />
    <ajaxToolKit:ModalPopupExtender ID="mdlDetailView" runat="server" 
        BehaviorID="detailView" 
        TargetControlID="btnShowEdit" 
        PopupControlID="pnlPopup" 
        CancelControlID="btnClose" BackgroundCssClass="modalBackground" 
        PopupDragHandleControlID="pnlDrag" />
        
    <asp:Panel ID="pnlDrag" runat="server" CssClass="corner-bg x-pne-lt x-pne-left">
        <div class="corner-bg x-pne-rt x-pne-right">
            <div class="corner-bg x-pne-t dragTitle">
                <div class="x-pne-btn" id="Div1" onclick="$find('detailView').hide();"></div>
                <div class="x-pne-caption font dragTitle"><span>请选择任务负责人</span></div>
            </div>
        </div>
    </asp:Panel>

    <div>
    
        <div class="side-bg x-pne-l">
            <div class="side-bg x-pne-r">
                <div class="x-pne-c" style="WIDTH: 448px;">
					<div style="margin:10px;font-size:9pt;" class="wrapper">
					
<div id="div2" style="width:430px;height:300px; overflow:auto;">
<asp:TreeView ID="tvEmp" runat="server" EnableViewState="true" OnLoad="tvEmp_Load"></asp:TreeView>
</div>
                    <!-- 下面是确认按钮 -->
                    <div style="width:328px; margin-top:16px;">
                        <table  style="width:100%; margin-left:40px;">
                            <tr>
                                <td>
<div class="btn-side btn-bg"></div>
<div class="btn-body btn-bg" style="background-position: 0px 168px; width: 66px"><asp:Button ID="btnOK" runat="server" Text="  确定  " CssClass="font" OnClick="btnOK_Click" /></div>
<div class="btn-side btn-bg" style="background-position: 0px 189px"></div>

                                </td>
                                <td>
<div class="btn-side btn-bg"></div>
<div class="btn-body btn-bg" style="background-position: 0px 168px; width: 66px;"><asp:Button ID="btnClose" runat="server" Text="  取消  " CssClass="font" /></div>
<div class="btn-side btn-bg" style="background-position: 0px 189px"></div>
                                </td>
                            </tr>
                        </table>
                    </div>
                        
					</div>
                </div>
            </div>
        </div>

        <div class="corner-bg x-pne-lb x-pne-left">
            <div class="corner-bg x-pne-rb x-pne-right">
                <div class="corner-bg x-pne-b"></div>
            </div>
        </div>
        
    </div>
    
    </ContentTemplate>
    </asp:UpdatePanel>
</asp:Panel>

<asp:updateprogress id="updateProgress"  runat="server">
    <progresstemplate>
        <div id="progressBackgroundFilter"></div>
        <div id="processMessage">正在处理数据，请稍等...<br /><br /><img alt="Loading" src="../images/loading_16.gif" /></div>
    </progresstemplate>
</asp:updateprogress>

<asp:Literal ID="lblJavaScript" EnableViewState="false" runat="server"></asp:Literal>

<script type="text/javascript">
    var ddlCategory = document.getElementById("<%= ddlCategory.ClientID %>");
    var applicationCode = document.getElementById("<%= txtApplicationCode.ClientID %>");
    var approvedByTextBox = document.getElementById("<%= txtApprovedBy.ClientID %>"); 
function selectAll()
{
    var tree = document.getElementById("<%=tvEmp.ClientID%>");
    if(typeof(tree) === "undefined" && tree === null) return;
    
    var checkBoxs = tree.getElementsByTagName('INPUT');
    for(var i = 0; i < checkBoxs.length; i++)
    {
        if(checkBoxs[i].type == "checkbox")
        {
            checkBoxs[i].checked = true;
        }
    }
}

function reverse()
{
    var tree = document.getElementById("<%=tvEmp.ClientID%>");
    if(typeof(tree) === "undefined" && tree === null) return;
    
    var checkBoxs = tree.getElementsByTagName('INPUT');
    for(var i = 0; i < checkBoxs.length; i++)
    {
        if(checkBoxs[i].type == "checkbox")
        {
            checkBoxs[i].checked = !checkBoxs[i].checked;
        }
    }
}

function OnTreeNodeChecked() 
{ 
    var ele = window.event.srcElement;
    if(ele.type=='checkbox')
    {
        var childrenDivID = ele.id.replace('CheckBox','Nodes');
        var div = document.getElementById(childrenDivID);
        if(div == null)return;
        var checkBoxs = div.getElementsByTagName('INPUT');
        for(var i=0;i<checkBoxs.length;i++)
        {
            if(checkBoxs[i].type=='checkbox')
                checkBoxs[i].checked=ele.checked;
        }
    }
}

function clientValidate() {
    alert(approvedByTextBox.value);
    return false;
}

 //$addHandler (element, "click", clickHandler); 
//jQuery("#<%=tvEmp.ClientID%>").click(
//function(){
//    alert('ss');
//});

jQuery(applicationCode).blur(function() {
    if (applicationCode.value.length == 0) return;
    var id = jQuery.getQueryString({ id: "id" });
    if (id != null && id.length == 36) return;
    jQuery.get('TaskHandler.ashx?op=applicationcode&code=' + applicationCode.value, function(result) {
        if (result == "1") {
            alert("申请编号已存在，请修改！");
        }
    });
});

</script>